package {
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import fwk.form.elements.QuestionComboBox;
	import fwk.form.elements.QuestionRadioCheck;
	import fwk.form.elements.ReponseComboBox;
	import fwk.form.FormManager;
		
		
	public class formExemple extends MovieClip
	{
		
		private var _managerQuestions:FormManager;

		
		public function formExemple() {
			
			var xmlFormConfig:XML = <form>
							<question	id="login" value="login" type="text" required="true" testType=''  codeError='error5' />
							<question	id="secret" value="secret" type="comboBox" required="true" testType=''  codeError='error5'>
								<item idLibrary="mcComboBoxItem" id="item1" value="1" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
								<item idLibrary="mcComboBoxItem" id="item2" value="2" />
							</question>
							<question	id="secretAnswer" value="secretAnswer" type="text" required="true" testType=''  codeError='error5' />
							<question	id="start" value="start" type="radioButton" required="true" testType=''  codeError='error2'>
								<rep id="radio1" value="1" zoneText="true" />
								<rep id="radio2" value="2" zoneText="true" />
								<rep id="radio3" value="3" zoneText="true" />
							</question>
						</form>;



			// gestion questions form

			_managerQuestions = new FormManager();
			_managerQuestions.init(mc, xmlFormConfig, true, stage);
			_managerQuestions.buttonConfirm = butValid;
			
			// set texte items comboBox
			var questionComboBox:QuestionComboBox = _managerQuestions.getQuestion("secret") as QuestionComboBox;
			questionComboBox.textPromp = "select";
			questionComboBox.comboBox.texte.tTexte.text = questionComboBox.textPromp;
			for (var i:int = 0; i < questionComboBox.reponsesTab.length; i++) 
			{
				var item:ReponseComboBox = questionComboBox.getItemAt(i);
				item.mc.texte.tTexte.text = "item" + i;
			}


			butValid.buttonMode = true;
			butValid.mouseChildren = false;
			butValid.addEventListener(MouseEvent.CLICK, onValidate);
			
			_managerQuestions.tabulation = true;
			_managerQuestions.rollOver = true;
			_managerQuestions.colorShapeFocus = 0xff4589;
			_managerQuestions.shapeFocus = true;
			
			

		}
		
		function onValidate(evt:MouseEvent):void
		{
				var tabError:Array = _managerQuestions.check();
				
				trace("tabError " + tabError.length);
				
				if ( tabError.length > 0)
				{
					trace("error 1 " + tabError[0]);
					
				}else {
					trace("aucune erreur !");
					
				}
		}
		
		


	}
	
	
}